#include "Tree.cc"

class BST:public Tree
{
public:
    BST() { ; }
    BST(vector<int> nums) : BST()
    {
        for (auto &num : nums)
            this->insert(num);
    }
    PNode insert(int);
    ~BST();
};

int main()
{
    vector<int> nums = {4,6,1,9,10};
    Tree* tree = new Tree(nums);
    Tree *bst = new BST(nums);
    delete tree;
    delete bst;
    // system("pause");
    return 0;
}


PNode BST::insert(int val)
{
    PNode *thisnode = &(this->root);
    while (*thisnode)
    {
        thisnode =
            (*thisnode)->val < val ? &((*thisnode)->r) : &((*thisnode)->l);
    }
    *thisnode = new Node(val);
    return *thisnode;
}

BST::~BST() { ; }
